<div>001</div>
<div>002</div>
<div>003</div>

<script>
    //1 匿名函数  函数自调用
    //2 细节
    //匿名函数最前面有;
    //匿名函数有一个实参，两个形参

    // 加；是为了保险起见
    let test = 666;
    ; (function (window, underfined) {
        function init() {
            let els = document.querySelectorAll(el)
            //     // 获取所有数据
            //     let els = document.querySelectorAll(el)
            for (let i = 0; i < els.length; i++) {
                this[i] = els[i] //this全等于实例化对象
            }
            this.length = els.length
        }
        let jQuery = function (el) {
            return new init(el)
        }

        jQuery.extend = function (object) {
            for (let key in object) {
                init.prototype[key] = object.key
            }
        }
        init.prototype = {
            css(cssAttr, cssVal) {
                console.log(1, this);
                // this[0].style.cssAttr = cssVal
                // this[1].style.cssAttr = cssVal
                // this[2].style.cssAttr = cssVal

                for (let i = 0; i < this.length; i++) {
                    this[i].style[cssAttr] = cssVal
                }
                return this
            },
            ajax(Option) { },
            attr(Option) { },
            addClass(Options) { },
        }



        //可以通过 赋值给window在对象外面使用
        window.jQuery = window.$ = jQuery
    })(window)

    // let jqobj = $('div')
    // console.log(jqobj);
    // jqobj.css('color', 'skyblue').css('background', 'green')

    $.extend({
        bg() {

        }
    })
    console.log($('div'));
</script>